﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NFLDriver
{
    //class that represents a user and their state
    public class User
    {
        //variables
        private string firstName = "";
        private string lastName = "";
        private string email = "";
        private string password = "";
        private bool loggedin = false;
        private Team[] selectedTeams = new Team[7];

        //default constructor
        public User()
        {
            for (int i = 0; i < 7; i++)
            {
                selectedTeams[i] = new Team();
                
                
            }
        }

        public User(string FirstName, string LastName, string Email, string Password)
        {
            firstName = FirstName;
            lastName = LastName;
            email = Email;
            password = Password;
            for (int i = 0; i < 7; i++)
            {
                selectedTeams[i] = new Team();


            }
        }

        public string FirstName
        {
            get
            {
                return firstName;
            }
            set
            {
                firstName = value;
            }
        }
        public string LastName
        {
            get
            {
                return lastName;
            }
            set
            {
                lastName = value;
            }
        }
        public string Email
        {
            get
            {
                return email;
            }
            set
            {
                email = value;
            }
        }
        public string Password
        {
            get
            {
                return password;
            }
            set
            {
                password = value;
            }
        }

        public bool loggedIn()
        {
            return loggedin;
        }
        //1 for true, anything else for false
        public void setLogIn(int loginResults)
        {
            if (loginResults == 1)
            {
                loggedin = true;
            }
            else
            {
                loggedin = false;
            }
        }
        
        //returns team at index; valid values are 0 - 6
        public Team getSelectedTeam(int index)
        {
            if ((index < 7) && (index >= 0))
            {
                return selectedTeams[index];
            }
            else
            {
                MessageBox.Show("Invalid parameter at User.getSelectedTeam.\nindex = " + index, "Invalid parameter", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }
        }

        //sets the team to the index in the selected teams array
        public void setSelectedTeam(int index, Team team)
        {
            if ((index < 7) && (index >= 0))
            {
                selectedTeams[index] = team;
            }
            else
            {
                MessageBox.Show("Invalid parameter at User.setSelectedTeam.\nindex = " + index, "Invalid parameter", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

    }
}
